﻿namespace CSharpPro._1016;

public class demo
{
    //作业一:键盘输入三个整数x、y、z，请把这三个数由小到大输出
    Public static void compare_number()
    {
        Console.WriteLine("请输入三个整数：");
        int x = Convert.ToInt32(Console.ReadLine());
        int y = Convert.ToInt32(Console.ReadLine());
        int z = Convert.ToInt32(Console.ReadLine());
        if (x < y && x < z)
        {
            if (y < z)
            {
                Console.WriteLine(x + "<" + y + "<" + z);
            }
            else
            {
                Console.WriteLine(x + "<" + z + "<" + y);
            }
        }
        else if (y < x && y < z)
        {
            if (x < z)
            {
                Console.WriteLine(y + "<" + x + "<" + z);
            }
        }
    }
    //作业二：打印出1-100之间所有不是7的倍数和不包含7的数字， 并求和
    public static void print()
    {
        int sum = 0;
        for (int i = 1; i <= 100; i++)
        {
            if (i % 7 != 0&& i%10!=7 && i / 10 != 7)
            {
                Console.Write(i + " ");
                sum += i;
            }
        }
        Console.WriteLine("\n" + "和为：" + sum);
    }
    //作业三：打印九九乘法表
    public static void print_multiplication_table()
    {
        for (int i = 1; i <= 9; i++)
        {
            for (int j = 1; j <= i; j++)
            {
                Console.Write(i + "*" + j + "=" + i * j + " ");
            }
            Console.WriteLine();
        }
    }
    //作业四：一个数如果恰好等于它的所有真因子（即除了自身 外的所有因数）之和，这个数就称为"完数"。请编程求出1000以内的所有完数。
    public static void print_complete_number()
    {
        for (int i = 1; i <= 1000; i++)
        {
            int sum = 0;
            for (int j = 1; j < i; j++)
            {
                if (i % j == 0)
                {
                    sum += j;
                }
            }
            if (sum == i)
            {
                Console.WriteLine(i);
            }
        }
    }
    //作业五：键盘录入一个正整数，请求：1.它是几位数？2.逆序打印出各位数字
    public static void print_number()
    {
        Console.WriteLine("请输入一个正整数：");
        int number = Convert.ToInt32(Console.ReadLine());
        int count = 0;
        int temp = number;
        while (temp != 0)
        {
            temp /= 10;
            count++;
        }
        Console.WriteLine("位数为：" + count);
        //逆序打印输出
        while (number != 0)
        {
            Console.Write(number % 10 );
            number /= 10;
        }
    }
    //作业六：打印菱形，根据输入的行数，显示菱形形状
    public static void print_diamond()
    { 
        Console.WriteLine("请输入行数：");
        int n = Convert.ToInt32(Console.ReadLine());
        for (int i = 1; i <= n; i++)
        {
            for (int j = 1; j <= n - i; j++)
            {
                Console.Write(" ");
            }
            for (int k = 1; k <= 2 * i - 1; k++)
            {
                Console.Write("*");
            }
            Console.WriteLine();
        }
    }
    
}